{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "228434fb",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (696690593.py, line 26)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [164]\u001b[1;36m\u001b[0m\n\u001b[1;33m    else:\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "# 用户输入余额\n",
    "balance = int(input (\"Please input balance:\"))\n",
    "# 定义商品\n",
    "commodity = [[\"pants\", 100], [\"T-shirt\",50], [\"skirt\", 20]]\n",
    "# 个人所得，包括金线和获牧的物易\n",
    "haveGoods = [balance, []]\n",
    "flag = True\n",
    "while flag:\n",
    "# 打印商品列表\n",
    " print (\"The commodity list is as follows\")\n",
    "print(\"____commodityList____.\" )\n",
    "i = 1;\n",
    "for c in commodity:\n",
    "    print ('The number:',i,\":\",c)\n",
    "i += 1\n",
    "# 用户輸入商品编号\n",
    "code = int (input (\"Please choose the number:\"))\n",
    "# 判断钱是否够用\n",
    "if commodity [code - 1][1] <= haveGoods [0]:\n",
    "# 在自己的购物清单中加入已购物品\n",
    " haveGoods[1].append(commodity[code-1])\n",
    "# 减去花费的金钱\n",
    "haveGoods [0] -= commodity[code-1][1]\n",
    "print (\"You have successfully purchased!\")\n",
    "print(\"Your account balance is:\",haveGoods [0])\n",
    "else:\n",
    "print (\"Your account balance is insufficient!\") print (\"Your account balance is:\", haveGoods [0])\n",
    "judge = input(\"You can press any button to continue,or input 'n' to leave:\")\n",
    "if judge == \"n\"：\n",
    "flag = False\n",
    "print (\"Your account balance is:\" , haveGoods [0])\n",
    "print(\"Your shopping list is as follows:\")\n",
    "print(\"____commodityList_____\")\n",
    "for h in haveGoods [1]:\n",
    "print (h)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "id": "026a9ad5",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (2935527742.py, line 19)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [161]\u001b[1;36m\u001b[0m\n\u001b[1;33m    print(\"The clothes list is as follows\")\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    " # 用户输入工资\n",
    "\n",
    "balance = int(input(\"Please input balance:\"))\n",
    "\n",
    "# 定义衣服的数组\n",
    "\n",
    "clothes = [[\"pants\",100],[\"T-shirt\",50],[\"skirt\",20]]\n",
    "\n",
    "# 个人所得，包括金钱和获取的物品\n",
    "\n",
    "haveGoods = [balance,[]]\n",
    "\n",
    "flag = True\n",
    "\n",
    "while flag:\n",
    "\n",
    "# 打印衣服列表\n",
    "\n",
    "print(\"The clothes list is as follows\")\n",
    "\n",
    "print(\"______clothesList______\")\n",
    "\n",
    "i = 1;\n",
    "\n",
    "for c in clothes:\n",
    "\n",
    "print('The number:',i,\":\",c)\n",
    "\n",
    "i += 1\n",
    "\n",
    "# 用户输入商品编号\n",
    "\n",
    "code = int(input(\"Please choose the number:\"))\n",
    "\n",
    "# 判断钱是否够用\n",
    "\n",
    "if clothes[code-1][1] <= haveGoods[0]:\n",
    "\n",
    "# 在自己的购物清单中加入已购物品\n",
    "\n",
    "haveGoods[1].append(clothes[code-1])\n",
    "\n",
    "# 减去花费的金钱\n",
    "\n",
    "haveGoods[0] -= clothes[code-1][1]\n",
    "\n",
    "print(\"You have successfully purchased!\")\n",
    "\n",
    "print(\"Your account balance is:\",haveGoods[0])\n",
    "\n",
    "else:\n",
    "\n",
    "print(\"Your account balance is insufficient!\")\n",
    "\n",
    "print(\"Your account balance is:\",haveGoods[0])\n",
    "\n",
    "judge = input(\"You can press any button to continue,or input 'n' to leave:\")\n",
    "\n",
    "if judge == \"n\":\n",
    "\n",
    "flag = False\n",
    "\n",
    " print(\"Your account balance is:\",haveGoods[0])   \n",
    "    print(\"Your shopping list is as follows:\")\n",
    "          print(\"______clothesList______\")\n",
    "\n",
    "for h in haveGoods[1]:\n",
    "\n",
    "print(h)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40912933",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c975a41",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
